<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<table class="easyui-datagrid" id="itemParamList" title="用户列表" 
       data-options="singleSelect:false,collapsible:true,pagination:true,url:'/manage/user/list.do',method:'get',pageSize:30,toolbar:itemParamListToolbar">
    <thead>
        <tr>
        	<th data-options="field:'ck',checkbox:true"></th>
        	<th data-options="field:'userId',width:60">ID</th>
        	<th data-options="field:'username',width:80">用户名</th>
        	<th data-options="field:'realname',width:80">真实项目</th>
            <th data-options="field:'phone',width:80">手机号</th>
            <th data-options="field:'email',width:80">email</th>
            <th data-options="field:'genderName',width:80">性别</th>
            <th data-options="field:'birthday',width:80">生日</th>
            <th data-options="field:'address',width:80">住址</th>
            <th data-options="field:'roleName',width:80">角色</th>
            <th data-options="field:'freezeStr',width:80">状态</th>
            <th data-options="field:'lastLoginTime',width:130,align:'center',formatter:E3.formatDateTime">最后登录时间</th>
            <th data-options="field:'createTime',width:130,align:'center',formatter:E3.formatDateTime">创建日期</th>
            <th data-options="field:'updateTime',width:130,align:'center',formatter:E3.formatDateTime">更新日期</th>
        </tr>
    </thead>
</table>
<div id="itemEditWindow" class="easyui-window" title="编辑商品" data-options="modal:true,closed:true,iconCls:'icon-save',href:'/item-edit'" style="width:80%;height:80%;padding:10px;">
</div>
<script>

	function formatItemParamData(value , index){
		var json = JSON.parse(value);
		var array = [];
		$.each(json,function(i,e){
			array.push(e.group);
		});
		return array.join(",");
	}

    function getSelectionsIds(){
    	var itemList = $("#itemParamList");
    	var sels = itemList.datagrid("getSelections");
    	var ids = [];
    	for(var i in sels){
    		ids.push(sels[i].userId);
    	}
    	ids = ids.join(",");
    	return ids;
    }
    
    var itemParamListToolbar = [{
        text:'冻结',
        iconCls:'icon-remove',
        handler:function(){
        	var ids = getSelectionsIds();
        	if(ids.length == 0){
        		$.messager.alert('提示','未选中用户!');
        		return ;
        	}
        	$.messager.confirm('确认','确定冻结ID为 '+ids+' 的用户吗？',function(r){
        	    if (r){
        	    	var params = {"id":ids};
                	$.post("/manage/user/freeze.do",params, function(data){
            			if(data.status == 0){
            				$.messager.alert('提示','冻结用户成功!',undefined,function(){
            					$("#itemParamList").datagrid("reload");
            				});
            			}
            		});
        	    }
        	});
        }
    },{
        text:'解冻',
        iconCls:'icon-remove',
        handler:function(){
        	var ids = getSelectionsIds();
        	if(ids.length == 0){
        		$.messager.alert('提示','未选中用户!');
        		return ;
        	}
        	$.messager.confirm('确认','确定解冻ID为 '+ids+' 的用户吗？',function(r){
        	    if (r){
        	    	var params = {"id":ids};
                	$.post("/manage/user/unfreeze.do",params, function(data){
            			if(data.status == 0){
            				$.messager.alert('提示','解冻用户成功!',undefined,function(){
            					$("#itemParamList").datagrid("reload");
            				});
            			}
            		});
        	    }
        	});
        }
    }];
</script>